﻿Public Class ViewModelParametrerGeneration
    Inherits ViewModelTabSectionBase

    Dim _AvailableGenerations As ObjectModel.ObservableCollection(Of Double)

    Public ReadOnly Property CorrespGenTarifCompt As DataView
        Get
            Dim manager As New DataManager
            Return manager.Dataset.CorrespondanceGenTarifComptable.DefaultView
        End Get
    End Property

    Public ReadOnly Property AvailableGenerations As ObjectModel.ObservableCollection(Of Double)
        Get
            If _AvailableGenerations Is Nothing Then

                Dim manager As New DataManager

                Dim q = (From elt In manager.Dataset.ReferenceCrt
                        Join elt2 In manager.Dataset.CorrespondanceGenTarifComptable
                        On elt.Generation_Tarif Equals elt2.Generation_Tarif
                        Select elt2.Generation_Comptable Distinct).ToList()

                If q.Count = 0 Then
                    q.Add(0.0)
                End If

                For Each elt In Enumerable.Range(2007, (manager.AnneeReference - 2007) + manager.NombreProjection)
                    If Not q.Contains(CDbl(elt)) Then
                        q.Add(CDbl(elt))
                    End If
                Next

                _AvailableGenerations = New ObjectModel.ObservableCollection(Of Double)(From elt In q Select elt Order By elt)

            End If

            Return _AvailableGenerations
        End Get
    End Property

End Class
